package main

import "fmt"

type Computer interface {
	SetPrinter()
}

type Windows struct {
	Printer Printer `json:"printer"`
}

func (p *Windows) SetPrinter(printer Printer) {
	p.Printer = printer
}

type Printer interface {
	PrintData()
}

type Hp struct {
}

func (p *Hp) PrintData() {
	fmt.Println("打印中")
}
func main() {
	hp := Hp{}
	w := Windows{}

	w.SetPrinter(&hp) //这里为什么需要传入地址才行？
	w.Printer.PrintData()
}
